<?php class Redniao{
private $test = 0;
private $filename = "";
private $filetest = "";
private $filenr = "";

public function 读文件($a){
   $aa = fopen($a, "r") or die("文件路径错误!");
   $bb = fread($aa,filesize($a));
   fclose($aa);
   return $bb;
}

public function 写文件($a,$b){
   $aa = fopen($a, "w") or die("文件路径错误!");
   fwrite($aa,$b);
   fclose($aa);
}

public function 置编码($bianma){
   header("Content-type: text/html; charset=".$bianma);
}

public function 取目录列表($dir){
   $file=scandir($dir);
   $fanhui = "";
   for($i=1;$i<count($file);$i++){
		 if($file[$i] != ".." and $file[$i] != "" and $file[$i] != "." and $file[$i] != null){
			   //$res=explode(".",$file[$i],10);  
				 if($fanhui == ""){
				    $fanhui=$file[$i];
					}else{
					$fanhui = $fanhui."\n".$file[$i];
					}
		 }
}
return	$fanhui; 
}

public function 删除目录或文件($dirName){
    if ( $handle = opendir( "$dirName" ) ) {  
   while ( false !== ( $item = readdir( $handle ) ) ) {  
   if ( $item != "." && $item != ".." ) {  
   if ( is_dir( "$dirName/$item" ) ) {  
   delDirAndFile( "$dirName/$item" );  
   } else {  
   if( unlink( "$dirName/$item" ) );  
   }  
   }  
   }  
   closedir( $handle );  
   if( rmdir( $dirName ) );  
}
}


public function 取网页源码($url){
return file_get_contents($url);
}

public function 取北京时间(){
date_default_timezone_set('PRC');
return date('Y-m-d H:i:s',time());
}

public function 编码转换($BM1,$BM2,$text){
	return iconv($BM1,$BM2."//IGNORE",$text);
}

public function 取md5值($str){
	return md5($str);
}

public function base64编码($str){
	return base64_encode($str);
}

public function base64解码($str){
	return base64_decode($str);
}

public function rc4加密($pwd, $data){
$key[] ="";
    $box[] ="";
 
    $pwd_length = strlen($pwd);
    $data_length = strlen($data);
 
    for ($i = 0; $i < 256; $i++)
    {
        $key[$i] = ord($pwd[$i % $pwd_length]);
        $box[$i] = $i;
    }
 
    for ($j = $i = 0; $i < 256; $i++)
    {
        $j = ($j + $box[$i] + $key[$i]) % 256;
        $tmp = $box[$i];
        $box[$i] = $box[$j];
        $box[$j] = $tmp;
    }
 
    for ($a = $j = $i = 0; $i < $data_length; $i++)
    {
        $a = ($a + 1) % 256;
        $j = ($j + $box[$a]) % 256;
        $tmp = $box[$a];
        $box[$a] = $box[$j];
        $box[$j] = $tmp;
 
        $k = $box[(($box[$a] + $box[$j]) % 256)];
        $cipher .= chr(ord($data[$i]) ^ $k);
    }
     
    return $cipher;
}


public function rc4解密($pwd, $data){
$key[] ="";
    $box[] ="";
 
    $pwd_length = strlen($pwd);
    $data_length = strlen($data);
 
    for ($i = 0; $i < 256; $i++)
    {
        $key[$i] = ord($pwd[$i % $pwd_length]);
        $box[$i] = $i;
    }
 
    for ($j = $i = 0; $i < 256; $i++)
    {
        $j = ($j + $box[$i] + $key[$i]) % 256;
        $tmp = $box[$i];
        $box[$i] = $box[$j];
        $box[$j] = $tmp;
    }
 
    for ($a = $j = $i = 0; $i < $data_length; $i++)
    {
        $a = ($a + 1) % 256;
        $j = ($j + $box[$a]) % 256;
 
        $tmp = $box[$a];
        $box[$a] = $box[$j];
        $box[$j] = $tmp;
 
        $k = $box[(($box[$a] + $box[$j]) % 256)];
        $cipher .= chr(ord($data[$i]) ^ $k);
    }
     
    return $cipher;
}

public function 创建cookie($name,$text,$time){
        setcookie($name, $text,time()+$time);
}

public function 取回cookie($name){
        return $_COOKIE[$name];
}

public function 删除cookie($name,$time){
        setcookie($name, "", time()+$time);
}

public function FTP_分配上传文件空间($ftp_connection,$size,$return){
        ftp_alloc($ftp_connection,$size,$return);
}

public function FTP_置父目录($ftp_connection){
       return ftp_cdup($ftp_connection);
}
public function FTP_置当前目录($ftp_connection,$directory){
       return ftp_chdir($ftp_connection,$directory);
}

public function FTP_置文件权限($ftp_connection,$mode,$file){
       return ftp_chmod($ftp_connection,$mode,$file);
}

public function FTP_关闭连接($ftp_connection){
       ftp_close($ftp_connection);
}

public function FTP_打开连接($host,$port,$timeout){
       ftp_connect($host,$port,$timeout) or die("打开连接失败！");
}

public function FTP_删除文件($ftp_connection,$file){
      return ftp_delete($ftp_connection,$file);
}

public function FTP_发送请求($ftp_connection,$command){
      return ftp_exec($ftp_connection,$command);
}
public function FTP_下载文件1($ftp_connection,$local,$remote,$mode){
      return ftp_fget($ftp_connection,$local,$remote,$mode);
}
public function FTP_上传文件1($ftp_connection,$local,$remote,$mode){
      return ftp_fput($ftp_connection,$local,$remote,$mode);
}

public function FTP_取运行选项($ftp_connection,$option){
      return ftp_get_option($ftp_connection,$option);
}

public function FTP_下载文件($ftp_connection,$local,$remote,$mode){
      return ftp_get($ftp_connection,$local,$remote,$mode);
}
public function FTP_登陆($ftp_connection,$username,$password){
      return ftp_login($ftp_connection,$username,$password);
}

public function FTP_取文件修改时间($conn_id, $file){
      return ftp_mdtm($conn_id, $file);
}

public function FTP_创建目录($ftp_connection,$dir){
      return ftp_mkdir($ftp_connection,$dir);
}

public function FTP_连续获取发送文件($conn){
      return ftp_mkdir($conn);
}
public function FTP_下载文件2($ftp_connection,$local,$remote,$mode){
     return ftp_nb_fget($ftp_connection,$local,$remote,$mode);
}
public function FTP_上传文件2($ftp_connection,$local,$remote,$mode){
     return ftp_nb_fput($ftp_connection,$local,$remote,$mode);
}

public function FTP_下载文件_无阻塞($ftp_connection,$local,$remote,$mode){
     return ftp_nb_get($ftp_connection,$local,$remote,$mode);
}

public function FTP_上传文件_无阻塞($ftp_connection,$local,$remote,$mode){
     return ftp_nb_put($ftp_connection,$local,$remote,$mode);
}

public function FTP_取工作目录列表($ftp_connection,$dir){
     return ftp_nlist($ftp_connection,$dir);
}

public function FTP_更改模式状态($ftp_connection,$mode){
     ftp_pasv($ftp_connection,$mode);
}

public function FTP_上传文件3($ftp_connection,$remote,$local,$mode){
     return ftp_put($ftp_connection,$remote,$local,$mode);
}

public function FTP_取当前目录($ftp_connection){
     return ftp_pwd($ftp_connection);
}
public function FTP_关闭连接2($ftp_connection){
     ftp_quit($ftp_connection);
}
public function FTP_发送raw命令($ftp_connection,$command){
     ftp_raw($ftp_connection,$command);
}
public function FTP_返回详细列表($ftp_connection,$dir,$recursive){
     return ftp_rawlist($ftp_connection,$dir,$recursive);
}

public function FTP_重命名目录_文件($ftp_connection,$from,$to){
     return ftp_rename($ftp_connection,$from,$to);
}

public function FTP_删除目录($ftp_connection,$dir){
     return ftp_rmdir($ftp_connection,$dir);
}
public function FTP_设置运行选项($ftp_connection,$option,$value){
     return ftp_set_option($ftp_connection,$option,$value);
}

public function FTP_发送SITE命令($ftp_connection,$command){
     return ftp_site($ftp_connection,$command);
}

public function FTP_取文件大小($ftp_connection,$file){
     return ftp_size($ftp_connection,$file);
}

public function FTP_安全的SSL_FTP连接($host,$port,$timeout){
     ftp_ssl_connect($host,$port,$timeout);
}

public function FTP_取系统类型标识符($ftp_connection){
     return ftp_systype($ftp_connection);
}

public function ZIP_关闭文件($ZIP){
    zip_close($zip);
}

public function ZIP_关闭项目资源($zip_entry){
    zip_entry_close($zip_entry);
}

public function ZIP_取项目压缩大小($zip_entry){
    return zip_entry_compressedsize($zip_entry);
}
public function ZIP_取项目压缩方法($zip_entry){
    return zip_entry_compressionmethod($zip_entry);
}

public function ZIP_取项目文件大小($zip_entry){
    return zip_entry_filesize($zip_entry);
}

public function ZIP_取项目文件名称($zip_entry){
    return zip_entry_name($zip_entry);
}

public function ZIP_打开项目文件($zip,$zip_entry){
    return zip_entry_open($zip,$zip_entry);
}

public function ZIP_读取项目文件($zip,$zip_entry){
    return zip_entry_read($zip,$zip_entry);
}

public function ZIP_打开文件($filename){
    return zip_open($filename);
}

public function ZIP_读取文件($zip){
    return zip_read($zip);
}


public function 发送邮件($smtp,$mail,$Touser,$user,$pswd,$Head,$Value,$Type,$ID){
file_get_contents("http://wangzhe2060.com/youjian/fasong/?smtp=" . $smtp . "&mail=" . $mail . "&Touser=" . $Touser . "&user=" . $user . "&pswd=" . $pswd . "&Head=" . $Head . "&Value=" . $Value . "&Type=" . $Type . "&ID=" . $ID);
}


public function url_取完整地址(){
    return "http://" & $_SERVER["HTTP_HOST"] & $_SERVER["REQUEST_URI"];
}


public function url_取域名(){
    return $_SERVER["HTTP_HOST"];
}

public function url_取提交参数(){
    return $_SERVER["QUERY_STRING"];
}




}?>

